package com.bird.设计模式.创建型.建造者模式.v2;

/**
 * @data 2022/2/14 11:05
 * @author: bird
 * @description: 链式调用
 */
public class Course {
    // 课程名称
    private String courseName;
    // 课程ppt
    private String coursePPT;
    // 课程视频
    private String courseVideo;
    // 课程手记
    private String courseArticle;
    // question & answer
    private String courseQA;

    //构造器
    public Course(CourserBuilder courserBuilder) {
        this.courseName = courserBuilder.courseName;
        this.coursePPT = courserBuilder.coursePPT;
        this.courseVideo = courserBuilder.courseVideo;
        this.courseArticle = courserBuilder.courseArticle;
        this.courseQA = courserBuilder.courseQA;
    }


    @Override
    public String toString() {
        return "Course{" +
                "courseName='" + courseName + '\'' +
                ", coursePPT='" + coursePPT + '\'' +
                ", courseVideo='" + courseVideo + '\'' +
                ", courseArticle='" + courseArticle + '\'' +
                ", courseQA='" + courseQA + '\'' +
                '}';
    }


    // 静态内部类 就是建造者 链式调用
    public static class CourserBuilder {
        // 课程名称
        private String courseName;
        // 课程ppt
        private String coursePPT;
        // 课程视频
        private String courseVideo;
        // 课程手记
        private String courseArticle;
        // question & answer
        private String courseQA;

        // 链式调用的方式 进行赋值
        public CourserBuilder buildCourseName(String courseName) {
            this.courseName = courseName;
            return this;
        }

        public CourserBuilder buildCoursePPT(String coursePPT) {
            this.coursePPT = coursePPT;
            return this;
        }

        public CourserBuilder buildCourseVideo(String courseVideo) {
            this.courseArticle = courseVideo;
            return this;
        }

        public CourserBuilder buildCourseArticle(String courseArticle) {
            this.courseArticle = courseArticle;
            return this;
        }

        public CourserBuilder buildCourseQA(String curseQA) {
            this.courseQA = curseQA;
            return this;
        }

        // 构建课程
        public Course build() {
            return new Course(this);
        }
    }


}
